import React, { Component } from 'react'
import axios from 'axios';

export default class Proxy2 extends Component {
  handleFetch1 = () => {
    axios.get('/api1/65d55e87c87ce4342e1285ab/todos').then(
      response => console.log('请求成功', response.data),
      error => console.error(error),
    )
  }

  handleFetch2 = () => {
    axios.get('/api2/65d55e87c87ce4342e1285ab/todos').then(
      response => console.log('请求成功', response.data),
      error => console.error(error),
    )
  }

  render() {
    return (
      <div>
        <button onClick={this.handleFetch1}>点击我通过代理/api1发送请求</button>
        <hr />
        <button onClick={this.handleFetch2}>点击我通过代理/api2发送请求</button>
      </div>
    )
  }
}
